import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import webExtension from "@samrum/vite-plugin-web-extension";
import path from "path";
import { getManifest } from "./src/manifest";

// https://vitejs.dev/config/
export default defineConfig(({mode}) => {
  return {
    plugins: [
      vue(),
      /**支持 Chrome 扩展的构建 */
      webExtension({
        manifest: getManifest(mode)
      })
    ],
    resolve: {
      alias: {
        "@public": path.resolve(__dirname, "./public"),
        "@src": path.resolve(__dirname, "./src"),
      },
    },
    build: {
      // 禁用压缩代码
      // minify: !/^dev/.test(mode),
      minify: false,
      sourcemap: /^dev/.test(mode),
      outDir: path.resolve(__dirname, "./dist/" + mode + "/")
    }
  };
});
